import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:syn_4s/core/extension/int_extension.dart';

abstract class BaseKeepScreen extends StatefulWidget {

  const BaseKeepScreen({super.key});

  @override
  State<BaseKeepScreen> createState() => _BaseKeepScreenState();

  String title(BuildContext context) {
    return "";
  }

  Widget? leadingWidget(BuildContext context) {
    return null;
  }

  /// 右边按钮或控件
  List<Widget>? titleActions(BuildContext context) {
    return null;
  }
  Widget? body(BuildContext context){
    return null;
  }

  Widget buildCloseIcon() {
    return IconButton(
        onPressed: () {
          Get.back();
        },
        iconSize: 30.px,
        icon: const Icon(
          Icons.close,
          color: Colors.white,
        ));
  }
}

class _BaseKeepScreenState extends State<BaseKeepScreen> with AutomaticKeepAliveClientMixin{

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title(context)),
        actions: widget.titleActions(context),
        leading: widget.leadingWidget(context),
      ),
      body: widget.body(context),
    );
  }

  @override
  bool get wantKeepAlive => true;
}
